<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/btnplus.css" />
		<style type="text/css">
			html,body{
				background-color: #F7F8FA;
				overflow-y: auto;
				-webkit-overflow-scrolling:touch;
			}
			.add_adress{ margin-top: 10px; background-color: #fff; padding: 0 15px;}
			.add_adress .top{ position:relative;}
			.add_adress .top::after{ position:absolute; content: ""; left: 0; right: -15px; bottom: 0; border-top: 1px #d5d5d5 solid; transform: scaleY(0.5);}
			.add_adress .top img{ width: 14px; margin-right: 5px;}
			.add_adress .top .m_cell_ft p{ font-size: 14px; color: #9f9f9f; height:43px; line-height: 48px; }
			.add_adress .top .m_cell_ft img{ width: 6px; margin-left: 8px;}
			.add_adress .top b{ display: block; font-size: 15px; font-weight: 500; line-height: 40px; height: 40px; color: #202532;}
			.add_adress .top input{ display:block; border: 0; width: 100%; box-sizing: border-box; text-align: right; font-size: 13px; color: #666; padding: 12px 15px 12px 0; background: url(../../image/img_13.png) no-repeat right center; background-size: 6px auto;}
			.add_adress textarea{ display:block; width: 100%; border: 0; height: 45px; padding: 10px 0 0; font-size: 14px; color: #666; line-height: 23px;}
			.add_adress p{text-align:right; font-size: 14px; color: #999; line-height: 25px; padding-bottom: 5px;}
			.add_input{ margin-top: 10px; background-color: #fff; line-height:48px; padding: 0 15px;}
			.add_input li{ position:relative;}
			.add_input li:not(:last-child)::after{ position: absolute; content: ""; left: 0; bottom: 0; right: -10px; border-top: 1px #d5d5d5 solid; transform: scaleY(0.5);}
			.add_input b{ display:block; font-size: 15px; font-weight: 400; color: #333;}
			.add_input input{ display:block; border: 0; width: 100%; box-sizing: border-box; text-align: right; font-size: 14px; color: #333; padding: 12px 0;}
			.add_input input.on{ padding-right: 15px; background: url(../../image/img_13.png) no-repeat right center; background-size: 6px auto;}
			.add_nums{ margin-top: 10px; padding: 0 15px 15px; background-color: #fff;}
			.add_nums b{ display:block; font-size: 15px; font-weight: 400; color: #333; line-height: 40px;}
			.add_nums li{ width: 48%; background-color: #f2f3f5; border-radius: 3px; position: relative; overflow: hidden;}
			.add_nums input{ display:block; box-sizing: border-box; border: 0; padding: 12px 10px; width: 100%; font-size: 13px; color: #333; background-color: transparent;}
			.add_nums p{ position:absolute; right: 10px; top: 8px; font-size: 14px; color: #333;}
			.add_type { margin-top: 10px; background-color: #fff; padding-bottom: 5px;}
			.add_type b{ display:block; padding: 5px 15px 0; font-size: 15px; font-weight: 400; color: #333; line-height: 30px;}
			.add_type ul{ margin:0 15px; display:flex; flex-wrap: wrap; justify-content:space-between; }
			.add_type li{ font-size: 13px; width:33.33%; color: #333; line-height: 35px;}
			.add_type li:nth-child(3n+2){ text-align:center;}
			.add_type li:nth-child(3n){ text-align:right;}
			.add_type li span{ display:inline-block; vertical-align: top; height: 35px; padding-left: 20px; background: url(../../image/img_24.png) no-repeat left center; background-size: 15px auto;}
			.add_type li span.on{ background-image:url(../../image/img_25.png);}

			.add_adress  b i,.add_input b i,.add_nums b i,.upload b i,.add_long b i,.add_type b i{ font-size:13px; color:#CF4242; margin-left:5px; }
			
			.add_long{ background-color:#fff; margin-top: 10px; padding: 0 15px 6px;}
			.add_long b,.upload b{ display:block; font-size: 15px; color: #333; font-weight: 400; line-height: 40px;}
			.add_long input{ display:block; border: 0; width: 100%; margin: 6px 0; padding: 12px 10px; font-size: 13px; color: #333; background-color: #f6f6f6; border-radius: 3px; box-sizing: border-box;}
			.add_long textarea{ display:block; border: 0; width: 100%; box-sizing: border-box; height: 80px; padding: 5px 10px; border-radius: 3px; background-color: #f6f6f6; font-size: 13px; color: #666; line-height: 23px; margin-bottom: 5px;}
			.add_long li{ float:left; width: 23.5%; margin-right: 2%;margin-bottom: 8px; text-align: center; font-size: 13px; color: #333; line-height: 28px; background-color: #f6f6f6; border-radius: 3px;}
			.add_long li:nth-child(4n+4){ margin-right: 0;}
			.add_long li.on{ background-color: #3262F1; color: #fff;}
			
			.upload{ margin-top: 10px; padding: 0 15px 10px; background-color: #fff;}
			.upload li{ float:left; width: 70px; position: relative; margin-right: 4%; margin-bottom: 2%;}
			.upload li:nth-child(4n+4){ margin-right: 0;}
			.upload a{ display:block; position: relative; overflow: hidden;}
			.upload img{ width: 70px; height:70px; border-radius: 3px; object-fit: cover;}
			.upload input{ position:absolute; right: 0; top: 0; bottom: 0; opacity: 0;}
			.upload em{ position:absolute; right: -8px; top: -8px; width: 17px; height: 17px; border-radius: 50%; background: url(../../image/img_33.png); background-size: 100% auto;}
			.add_btn{ padding: 25px 15px 45px;}
			.color-333 { color: #333 !important; } 
			.display-none { display:none !important; }
			.showmore { background:#fff; height:36px; }
			.showmore img { width:18px; margin:0 auto; padding-top: 8px; }
			.grlb{ padding: 10px 15px 0;}
			.grlb p{ color: #333; line-height: 30px; height: 30px; position: relative; padding-left: 18px; font-size: 12px;}
			.grlb a{ display:inline; color: #1c63fa;}
			.grlb em{ position: absolute; left: 0; top: 8px; width: 13px; height: 13px; border-radius: 50%; background-image: url(../../image/img_24.png); background-size: 100% auto;}
			.grlb em.on{ background-image: url(../../image/img_25.png);}
			#test{
				width:30px;
				height: 30px;
				background:url("image/organization.png");
				float:left;
			}
			
			
			.test-normal{
				 transform: rotate(0deg);
	            -webkit-transform: rotate(0deg);
	            transition: transform .5s;
			}
			.img-inverse {
				animation: que .5s linear 1;
			}
			.test-inverse{
				transform: rotate(180deg);
	            -webkit-transform: rotate(180deg);
	            transition: transform .5s;
			}
			@keyframes que {
				0%{
					transform: rotate(0deg);
				}
				100%{
					transform: rotate(180deg);
				}
			}
		</style>
	</head>
	<body>
		<div class="add_adress">
			<ul class="top" tapmode="lipress" onclick="setCity('send');">
				<li class="m_cell_hd"><img src="../../image/img_42.png" alt="" /></li>
				<li class="m_cell_hd m_cell_primary"><b>出发地<i>*</i></b></li>
				<li class="m_cell_ft" id="sendarea"><p>请选择</p></li>
				<li class="m_cell_ft"><img src="../../image/img_13.png" alt="" /></li>
			</ul>
			<ul class="con">
				<textarea placeholder="请编辑出发地详细地址" class="limitinput" limit-num="50" id="sendaddress"></textarea>
				<p id="tishimsg1">0/50</p>
			</ul>
		</div>
		<div class="add_adress">
			<ul class="top" tapmode="lipress" onclick="setCity('dest');">
				<li class="m_cell_hd"><img src="../../image/img_41.png" alt="" /></li>
				<li class="m_cell_hd m_cell_primary"><b>目的地<i>*</i></b></li>
				<li class="m_cell_ft" id="destarea"><p>请选择</p></li>
				<li class="m_cell_ft"><img src="../../image/img_13.png" alt="" /></li>
			</ul>
			<ul class="con">
				<textarea placeholder="请编辑目的地详细地址" class="limitinput" limit-num="50" id="destaddress"></textarea>
				<p id="tishimsg2">0/50</p>
			</ul>
		</div>

		<div class="add_input">
		  <ul>
			<li>
					<div class="m_cell_hd"><b>货物名称<i>*</i></b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="goodsname" class="limitinput" limit-num="5" value="" placeholder="请输入货物名称" /></div>
				</li>
			</ul>
		</div>

		<div class="add_nums">
			<b>货物单位<i>*</i>（至少填写一项）</b>
			<ul class="clearfix">
				<li class="fl"><input type="number" id="goodsweight" value="" oninput="inputmaxlimit(this,1000);" onkeyup="checknumAndOnePoint(this)" placeholder="请输入数值" /><p>吨</p></li>
				<li class="fr"><input type="number" id="goodsvolume" value="" oninput="inputmaxlimit(this,1000);" onkeyup="checknumAndOnePoint(this)" placeholder="请输入数值" /><p>立方米</p></li>
			</ul>
		</div>

		<div class="add_input">
		  <ul>
			<li>
					<div class="m_cell_hd"><b>定金金额</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="number" id="depositfee" oninput="inputmaxlimit(this,1000.1);" onkeyup="checknumAndOnePoint(this)" value="" placeholder="接单时支付的金额最低50元" /></div>
				</li>
			<li>
					<div class="m_cell_hd"><b>运费金额</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="number" id="fee" onkeyup="checknum(this)" oninput="checknum(this)" value="" placeholder="请填写本单运费，仅用作展示" /></div>
				</li>
			<li>
					<div class="m_cell_hd"><b>支付方式</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" value="" oninput="inputlimit(this,10);" id="paytype" placeholder="请填写支付方式" /></div>
				</li>
			</ul>
		</div>

		<div class="add_input">
			<ul>
				<li tapmode="lipress" onclick="setLoadTime();">
					<div class="m_cell_hd"><b>选择装车时间<i>*</i></b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="loadtime" value="" placeholder="请选择" readonly class="on" /></div>
				</li>
			</ul>
		</div>

		<div class="add_type">
			<b>装卸类型<i>*</i></b>
			<ul id="transporttypelist">
			</ul>
			<script id="transporttypelist_template" type="text/template">
			<li tapmode data-transporttype="0" onclick="selTransporttypetype(this);"><span class="on">不限类型</span></li>
			{{ for (var i = 0, len = it.length; i < len; i++) { }}
			<li tapmode data-transporttype="{{=it[i].id}}" onclick="selTransporttypetype(this);"><span>{{=it[i].transporttypeName}}</span></li>
			{{ } }}
			</script>
		</div>

		<div class="add_long" id="cartypelist">
			<script id="cartypelist_template" type="text/template">
			<b>车型<i>*</i></b>
			<ul class="clearfix" id="cartypelist1">
			<li tapmode data-cartype="0" onclick="selCartype(this,1);" class="on">不限</li>
			{{ for (var i = 0, len = it.length; i < 11; i++) { }}
			<li tapmode data-cartype="{{=it[i].id}}" onclick="selCartype(this,0);">{{=it[i].cartypeName}}</li>
			{{ } }}
			</ul>
			{{? it.length > 11}}
			<ul class="clearfix display-none" id="cartypelist2">
			{{ for (var i = 11, len = it.length; i < len; i++) { }}
			<li tapmode data-cartype="{{=it[i].id}}" onclick="selCartype(this,0);">{{=it[i].cartypeName}}</li>
			{{ } }}
			</ul>
			<div class="showmore" tapmode onclick="changshowmore(this);"><img class="test-normal" src="../../image/zhankai.png"><span></span></div>
			
			{{??}}
			<ul class="clearfix display-none" id="cartypelist2"></ul>
			{{?}}
			</script>
		</div>

		<div class="add_long" id="carlenlist">
			
			<script id="carlenlist_template" type="text/template">
			<b>车长<i>*</i></b>
			<ul class="clearfix" id="carlenlist1">
			<li tapmode data-carlen="0" onclick="selCarlen(this,1);" class="on">不限</li>
			{{ for (var i = 0, len = it.length; i < 11; i++) { }}		
			<li tapmode data-carlen="{{=it[i].id}}" onclick="selCarlen(this,0);">{{=it[i].carlenName}}</li>
			{{ } }}
			</ul>
			{{? it.length > 11}}
			<ul class="clearfix display-none" id="carlenlist2">
			{{ for (var i = 11, len = it.length; i < len; i++) { }}
			<li tapmode data-carlen="{{=it[i].id}}" onclick="selCarlen(this,0);">{{=it[i].carlenName}}</li>
			{{ } }}
			</ul>
			<div class="showmore clearfix" tapmode onclick="changshowmore(this);"><img src="../../image/zhankai.png"><span></span></div>
			
			{{??}}
			<ul class="clearfix display-none" id="carlenlist2"></ul>
			{{?}}
			<input type="number" id="carlenother" oninput="inputlimit(this,4);" onkeyup="checknumAndOnePoint(this)" onblur="clearnolimit();" value="" placeholder="请输入其他车长" />
		
			</script>
		</div>

		<div class="add_long">
			<b>货物类型<i>*</i></b>
			<ul class="clearfix" id="goodstypelist">
			</ul>
			<script id="goodstypelist_template" type="text/template">
			{{ for (var i = 0, len = it.length; i < len; i++) { }}		
			<li tapmode data-goodstype="{{=it[i].id}}" onclick="selGoodstype(this);">{{=it[i].goodstypeName}}</li>
			{{ } }}
			</script>
		</div>

		<div class="add_long">
			<b>备注</b>
			<ul>
				<textarea id="memo" class="limitinput" limit-num="20" placeholder="请输入备注信息，20字以内"></textarea>
			</ul>
		</div>

		<div class="upload">
			<b>上传货物图片</b>
			<ul class="upload_imgs clearfix" id="imgslist">
				<li tapmode onclick="upimg();" id="delbtn"><img src="../../image/img_09.jpg" /></li>
			</ul>
		</div>
		<div class="grlb">
			<p><span tapmode onclick="agreenterm(this);"><em class="" id="btnagreen"></em>我已阅读并同意</span><a href="javascript:;" tapmode onclick="openNavWin('#ddd','goodterms_win','goodterms_frm.html','货物运输协议',false,false,true,[],{});">《货物运输协议》</a></p>
		</div>
		<div class="add_btn">
			<button class="d_btn" id="login-btn" tapmode="btnpress" onclick="addgoods();">发布货源</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/app.js"></script>
	<script type="text/javascript" src="../../script/permission.js"></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript">
		var sendlist = [], destlist = [];
		var sendprovinceId = ''; //省份编码
		var sendcityId = ''; //城市编码
		var sendareaId = '';  //县区编码
		var sendarea = ''; //客户地区
		
		var destprovinceId = ''; //省份编码
		var destcityId = ''; //城市编码
		var destareaId = '';  //县区编码
		var destarea = ''; //客户地区
		
		var timetype = 1; //1表示选择时间；0表示随时装车
		var loadingtime = ''; //装车时间
		var transporttype = 0; //用车类型
		var cartype = [];
		var carlen = []; //车长
		var goodstype = 0;//货物类型
		
		var arrimgs = []; //本地压缩后图片集
		var arrpic = [];
		var paytype = '';
		var entruckingtime = 0;
		var entruckingtimes = 0; //时间段
		var entruckingtimetype = 0;
		var aMap;
		apiready = function() {
			api.parseTapmode();
			getJsonFromAPI();
			aMap = api.require('aMap');
			api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'left') {
					api.closeWin({
					});
                }
            });
			api.addEventListener({
				name : 'reloadpage'
			}, function(ret, err) {
				getJsonFromAPI();
				
			});
			var flag = false
			var inputs = $api.domAll('.limitinput');
			for (var i = 0; i < inputs.length; i++) {
				inputs[i].oninput = function() {
					var limitnum = $api.attr(this,'limit-num');
					setTimeout(() => {
						if (!flag){
							var len = this.value.length;
							if(this.value.length > limitnum)
							{
								this.value = this.value.substr(0,limitnum);
								len = 50;
							}
							if(this.id == 'sendaddress') {
								$api.text($api.byId("tishimsg1"),len+'/50');
							}
							else if(this.id == 'destaddress') {
								$api.text($api.byId("tishimsg2"),len+'/50');
							}
						}
					}, 0);
				}
			}
			document.addEventListener('compositionstart', function(e) {
				flag = true;
			});
			document.addEventListener('compositionend', function(e) {
				flag = false;
			});
		}
		function setSendAddr(addrjson) {
			var sendaddr = $api.strToJson(addrjson);
			sendprovinceId = sendaddr.sendprovinceId;
			sendcityId = sendaddr.sendcityId;
			sendareaId = sendaddr.sendareaId;
			$api.html($api.byId('sendarea'),'<p class="color-333">'+sendaddr.sendarea+'</p>');
			if(sendaddr.address != '') {
				$api.val($api.byId('sendaddress'),sendaddr.address);
				
			}
		}
		function setDestAddr(addrjson) {
			var destaddr = $api.strToJson(addrjson);
			destprovinceId = destaddr.destprovinceId;
			destcityId = destaddr.destcityId;
			destareaId = destaddr.destareaId;
			$api.html($api.byId('destarea'),'<p class="color-333">'+destaddr.destarea+'</p>');
			if(destaddr.address != '') {
				$api.val($api.byId('destaddress'),destaddr.address);
				
			}
		}
		function setCity(type) {
			document.activeElement.blur();
			setTimeout(function(){
				setCityN(type)
			},200);
		}
		function setCityN(type) {
			var paramss = {};
			if(type == 'send') {
				paramss = {
					sendlist: sendlist,
					fromfrm: 'addgoods_win'
				};
			}
			else
			{
				paramss = {
					destlist: destlist,
					fromfrm: 'addgoods_win'
				};
			}
			api.openFrame({
				name: type+'filter_frm',
				url: type+'filter_frm.html',
				bounces: false,
				rect: {
					x: 0,
					y: 0,
					w: 'auto',
					h: 'auto'
				},
				bgColor: 'rgba(0,0,0,0.6)',
				pageParam: paramss
			});
		}
		function changshowmore2(obj) {
			$api.toggleCls(obj.firstElementChild, 'img-inverse');
		}
		function changshowmore(obj) {
			if($api.attr(obj.firstElementChild, 'src') == '../../image/zhankai.png')
			{
				if($api.hasCls(obj.previousElementSibling,'display-none')) {
					$api.removeCls(obj.previousElementSibling,'display-none')
				}
				$api.attr(obj.firstElementChild, 'src', '../../image/shouqi.png');
				
			}
			else
			{
				if(!$api.hasCls(obj.previousElementSibling,'display-none')) {
					$api.addCls(obj.previousElementSibling,'display-none')
				}
				$api.attr(obj.firstElementChild, 'src', '../../image/zhankai.png');
				
			}
		}
		function isRealNum(val){
			if(val === "" || val ==null){
				return false;
			}
			if(!isNaN(val)){
				return true;
			}else{
				return false;
			}
		}
		function inputmaxlimit(obj,maxval) {
			//限制输入框字数
			if(!isRealNum(obj.value))
			{
				if(obj.value != ''){
				obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
			else
			{
				if(obj.value >= maxval) {
					obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
		}
		function inputmaxlimitint(obj,maxval) {
			checknum(obj);
			//限制输入框字数
			if(!isRealNum(obj.value))
			{
				if(obj.value != ''){
				obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
			else
			{
				if(obj.value > maxval) {
					obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
		}
		function clearnolimit() {
			//输入自定义车长后取消不限按钮选中
			if($api.val($api.byId('carlenother'))!='')
			{
				$api.removeCls($api.byId('carlenlist').firstElementChild,'on');
			}
		}
		function checknumletter(obj) {
			//只允许数字和字母
			obj.value = obj.value.replace(/[^\w\.\/]/ig,"");
		}
		function checknum(obj) {
			//只允许整数
			if(obj.value.length==1){
				obj.value=obj.value.replace(/[^1-9]/g,'');
			}else{
				obj.value=obj.value.replace(/\D/g,'');
			}
			if(obj.value.length > 6)
			{
				obj.value = obj.value.substr(0,6);
			}

		}
		function checknumAndOnePoint(obj) {
			//只允许整数和一位小数
			//var v = $api.val(obj);
			obj.value = obj.value.replace(/[^\d.]/g,""); //先把非数字的都替换掉，除了数字和. 
			obj.value = obj.value.replace(/^\./g,""); //必须保证第一个为数字而不是. 
			obj.value = obj.value.replace(/\.{2,}/g,"."); //保证只有出现一个.而没有多个. 
			obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); //保证.只出现一次，而不能出现两次以上 
			if(obj.value.indexOf(".") > -1)
			{
				obj.value = obj.value.substr(0,obj.value.indexOf(".")+2); 
			}			
			//if(!/^\d+(\.\d{1,2})?$/.test(obj.value))
			//{
				//obj.value = '';
				//toast('只能输入整数和一位小数');
			//}
			
		}
		function checknumAndTwoPoint(obj) {
			//只允许整数和两位小数
			//var v = $api.val(obj);
			obj.value = obj.value.replace(/[^\d.]/g,""); //先把非数字的都替换掉，除了数字和. 
			obj.value = obj.value.replace(/^\./g,""); //必须保证第一个为数字而不是. 
			obj.value = obj.value.replace(/\.{2,}/g,"."); //保证只有出现一个.而没有多个. 
			obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); //保证.只出现一次，而不能出现两次以上 
			if(obj.value.indexOf(".") > -1)
			{
				obj.value = obj.value.substr(0,obj.value.indexOf(".")+3); 
			}			
			//if(!/^\d+(\.\d{1,2})?$/.test(obj.value))
			//{
				//obj.value = '';
				//toast('只能输入整数和一位小数');
			//}
			
		}
		function agreenterm(obj) {
			$api.toggleCls(obj.firstElementChild,'on');
		}
		function getJsonFromAPI() {
			//从接口获取查询数据
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/goodsextra',
						method: 'get',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						}
					}, function(ret, err) {
						//hideloading();
						if (ret) {
							console.log(JSON.stringify(ret));
							sendlist = ret.sendlist;
							destlist = ret.destlist;
							if(ret.goodsinfo.sendprovinceId!='')
							{
								sendprovinceId = ret.goodsinfo.sendprovinceId;
								sendcityId = ret.goodsinfo.sendcityId;
								sendareaId = ret.goodsinfo.sendareaId;
								
								$api.html($api.byId('sendarea'), '<p class="color-333">'+ret.goodsinfo.sendarea+'</p>');
								$api.val($api.byId('sendaddress'),ret.goodsinfo.sendaddress);
								$api.text($api.byId('tishimsg1'),ret.goodsinfo.sendaddress.length+'/50');
							}
							var transporttypelist = ret.transporttypelist;
							UpdateList('transporttypelist','transporttypelist_template',transporttypelist,false);
							
							var cartypelist = ret.cartypelist;
							UpdateList('cartypelist','cartypelist_template',cartypelist,true);
							
							var carlenlist = ret.carlenlist;
							UpdateList('carlenlist','carlenlist_template',carlenlist,true);
							
							var goodstypelist = ret.goodstypelist;
							UpdateList('goodstypelist','goodstypelist_template',goodstypelist,true);
						} else {
							if(err.statusCode==402)
							{
								Relogin();
							}
							else
							{
								console.log(JSON.stringify(err));
								toast('网络异常');
							}
						}
					});
				}
			});
		}
		function addgoods() {
			var sendaddress = $api.val($api.byId('sendaddress')).trim();
			var senddetailaddess = $api.text($api.byId('sendarea'))+''+sendaddress;
			var destaddress = $api.val($api.byId('destaddress')).trim();
			var destdetailaddess = $api.text($api.byId('destarea'))+''+destaddress;
			
			if(sendprovinceId=='')
			{
				showtoast("warning","请选择出发地");
				return false;
			}
			if(sendaddress=='')
			{
				showtoast("warning","请输入出发地详细地址");
				return false;
			}
			if(sendaddress.length<2)
			{
				showtoast("warning","详细地址不能少于2字");
				return false;
			}
			if(destprovinceId=='')
			{
				showtoast("warning","请选择目的地");
				return false;
			}
			if(destaddress=='')
			{
				showtoast("warning","请输入目的地详细地址");
				return false;
			}
			if(destaddress.length<2)
			{
				showtoast("warning","详细地址不能少于2字");
				return false;
			}
			var goodsposition = {
				sendlon: '',
				sendlat: '',
				destlon: '',
				destlat: ''
			};
			aMap.getCoordsFromName({
				city: sendareaId,
				address: senddetailaddess
			}, function(ret, err) {
				if (ret.status) {
					goodsposition.sendlon = ret.lon;
					goodsposition.sendlat = ret.lat;
					aMap.getCoordsFromName({
						city: destareaId,
						address: destdetailaddess
					}, function(ret, err) {
						if (ret.status) {
							//alert(JSON.stringify(ret));
							goodsposition.destlon = ret.lon;
							goodsposition.destlat = ret.lat;
							finaladdgoods(goodsposition);
						} else {
							showtoast("warning","请输入正确的目的地");
						}
					});
					//finaladdgoods(ret.lon,ret.lat);
				} else {
					showtoast("warning","请输入正确的出发地");
				}
			});
		}
		function finaladdgoods(goodsposition) {
			document.activeElement.blur();
			var sendaddress = $api.val($api.byId('sendaddress')).trim();
			var destaddress = $api.val($api.byId('destaddress')).trim();
			var depositfee = $api.val($api.byId('depositfee')).trim();
			var goodsname = $api.val($api.byId('goodsname')).trim();
			var fee = $api.val($api.byId('fee')).trim();
			
			var goodsweight = $api.val($api.byId('goodsweight')).trim();
			var goodsvolume = $api.val($api.byId('goodsvolume')).trim();
			
			var senddetailaddess = $api.text($api.byId('sendarea'))+''+destaddress;
			loadingtime = $api.val($api.byId('loadtime'));
			paytype = $api.val($api.byId('paytype'));
			
			var carlenother = $api.val($api.byId('carlenother'));
			
			if($api.cssVal($api.byId('login-btn'),'opacity')!=1)
			{
				return false;
			}
			if(sendaddress.length < 2)
			{
				showtoast("warning","详细地址不能少于2字");
				return false;
			}
			if(destaddress.length < 2)
			{
				showtoast("warning","详细地址不能少于2字");
				return false;
			}
			if(goodsname == '')
			{
				showtoast("warning","请填写货物名称");
				return false;
			}
			var re = /^[1-9]+[0-9]*]*$/;
			if(depositfee!='')
			{
				if (!re.test(depositfee))
				{
					showtoast("warning","定金金额只能输入整数");
					return false;
				}
				if (depositfee < 50)
				{
					showtoast("warning","定金金额不能小于50");
					return false;
				}
				if (depositfee > 1000)
				{
					showtoast("warning","定金金额不能大于1000");
					return false;
				}
			}
			if(fee!='')
			{
				if (!re.test(fee))
				{
					showtoast("warning","运费金额只能输入整数");
					return false;
				}
			}
			
			if(entruckingtime==0)
			{
				showtoast("warning","请选择装车时间");
				return false;
			}
			if(goodstype==0)
			{
				showtoast("warning","请选择货物类型");
				return false;
			}
			if(!$api.hasCls($api.byId('btnagreen'),'on'))
			{
				showtoast("warning","同意运输协议才可以下一步");
				return false;
			}
			carlen = [];
			var liList = document.getElementById("carlenlist1").children;
			var liList2 = document.getElementById("carlenlist2").children;
			for (var i = 0; i < liList.length; i++) {
				if($api.hasCls(liList[i], 'on'))
				{
					var curcarlen = parseInt($api.attr(liList[i],'data-carlen'));
					carlen.push(curcarlen);
				}
			}
			for (var i = 0; i < liList2.length; i++) {
				if($api.hasCls(liList2[i], 'on'))
				{
					var curcarlen = parseInt($api.attr(liList2[i],'data-carlen'));
					carlen.push(curcarlen);
				}
			}
			cartype = [];
			var liList3 = document.getElementById("cartypelist1").children;
			var liList4 = document.getElementById("cartypelist2").children;
			for (var i = 0; i < liList3.length; i++) {
				if($api.hasCls(liList3[i], 'on'))
				{
					var curcartype = parseInt($api.attr(liList3[i],'data-cartype'));
					cartype.push(curcartype);
				}
			}
			for (var i = 0; i < liList4.length; i++) {
				if($api.hasCls(liList4[i], 'on'))
				{
					var curcartype = parseInt($api.attr(liList4[i],'data-cartype'));
					cartype.push(curcartype);
				}
			}
			if(goodsweight=='' && goodsvolume=='')
			{
				showtoast("warning","货物单位至少填写一项");
				return false;
			}
			if(goodsweight==0 && goodsvolume==0)
			{
				showtoast("warning","总重量和总体积不能都为0");
				return false;
			}
			showbtnloading('login-btn');
			api.showProgress({
				title: '请稍后...',
				text: '',
				modal: true
			});
			
			var imgs = [];
			var paramsObj = {
				sendprovinceId: sendprovinceId,
				sendcityId: sendcityId,
				sendareaId: sendareaId,
				sendaddress: sendaddress,
				sendlon : goodsposition.sendlon,
				sendlat : goodsposition.sendlat,
				destprovinceId: destprovinceId,
				destcityId: destcityId,
				destareaId: destareaId,
				destaddress: destaddress,
				destlon : goodsposition.destlon,
				destlat : goodsposition.destlat,
				goodsname: goodsname,
				depositfee: depositfee,
				fee: fee,
				paytype: paytype,
				entruckingtime: entruckingtime,
				entruckingtimes: entruckingtimes,
				entruckingtimetype: entruckingtimetype,
				transporttype: transporttype,
				cartype: cartype,
				carlen: carlen,
				carlenother: carlenother,
				goodstype: goodstype,
				goodsweight: goodsweight,
				goodsvolume: goodsvolume,
				memo: $api.val($api.byId('memo'))
			}
			var imgList = document.getElementsByClassName("addimg");

			var sucbase64 = 0;
			var allbase64 = imgList.length; //所有带转换的数量
			if(allbase64 > 0)
			{
				for (var i = 0; i < imgList.length; i++) {
					var picurl = $api.attr(imgList[i].children[0],'src');
					//imgs.push($api.attr(imgList[i].children[0],'src'));
					var trans = api.require('trans');
					trans.decodeImgToBase64({
						imgPath: picurl
					}, function(ret, err) {
						if (ret.status) {
							//转换成base64后上传
							imgs.push('data:image/jpeg;base64,'+ret.base64Str);
							sucbase64++;
							if(sucbase64 == allbase64)
							{
								finalpost(paramsObj,imgs);
							}
						}
					});
				}
				console.log(JSON.stringify(imgs));
			}
			else
			{
				finalpost(paramsObj,imgs);
			}
			
		}
		function finalpost(paramsObj,imgs) {
			//最终提交
			paramsObj.base64str = imgs;
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret && ret.value)
				{
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/goods',
						method: 'post',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						},
						data: {
							values: paramsObj
						}
					}, function(ret, err) {
						api.hideProgress();
						if (ret) {
							openAlert();
						} else {
							//alert(JSON.stringify(err));
							toast(err.body.message);
						}
						hidebtnloading('login-btn','发布货源信息');
					});
				}
			});
		}
		function openAlert()
		{
			var icon = 'sucess.png';
			var title = '货源发布成功';
			var msg = '请等待车主接单';
			var winname = 'root';
			var btntxt = '返回';
			var param = {
				icon: icon,
				title: title,
				msg: msg,
				btntxt: btntxt,
				winname: winname,
			};
			openNavWin('#ddd','noheadmsg_win','../public/noheadmsg_frm.html','发布货源',false,true,false,[],param);
		}
		function funcChina(str){ 
			if(/.*[\u4e00-\u9fa5]+.*$/.test(str)) 
			{ 
				//alert("不能含有汉字！"); 
				return false; 
			} 
			return true; 
		}
		function selTransporttypetype(obj) {
			document.activeElement.blur();
			transporttype = $api.attr(obj,'data-transporttype');
			var liList = document.getElementById("transporttypelist").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i].firstElementChild, 'on')
			}
			$api.toggleCls(obj.firstElementChild,'on');
		}
		function selPaytype(obj) {
			document.activeElement.blur();
			paytype = $api.attr(obj,'data-paytype');
			var liList = document.getElementById("paylist").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i], 'on')
			}
			$api.toggleCls(obj,'on');
		}
		function selCartype(obj,id) {
			document.activeElement.blur();
			if(id == 1)
			{
				var liList = document.getElementById("cartypelist1").children;
				var liList2 = document.getElementById("cartypelist2").children;
				for (var i = 0; i < liList.length; i++) {
					$api.removeCls(liList[i], 'on')
				}
				for (var i = 0; i < liList2.length; i++) {
					$api.removeCls(liList2[i], 'on')
				}
			}
			else
			{
				var liList = document.getElementById("cartypelist1").children;
				var liList2 = document.getElementById("cartypelist2").children;
				$api.removeCls(liList[0], 'on');
				var checklinum = 0;
				for (var i = 0; i < liList.length; i++) {
					if($api.hasCls(liList[i], 'on')) {
						checklinum++;
					}
				}
				for (var i = 0; i < liList2.length; i++) {
					if($api.hasCls(liList2[i], 'on')) {
						checklinum++;
					}
				}
				if(!$api.hasCls(obj, 'on') && checklinum>2) {
					toast('车型最多选择三项');
					return;
				}
			}
			$api.toggleCls(obj,'on');
		}
		function selCarlen(obj,id) {
			document.activeElement.blur();
			if(id == 1)
			{
				var liList = document.getElementById("carlenlist1").children;
				var liList2 = document.getElementById("carlenlist2").children;
				for (var i = 0; i < liList.length; i++) {
					$api.removeCls(liList[i], 'on')
				}
				for (var i = 0; i < liList2.length; i++) {
					$api.removeCls(liList2[i], 'on')
				}
				$api.val($api.byId('carlenother'),'');
			}
			else
			{
				var liList = document.getElementById("carlenlist1").children;
				var liList2 = document.getElementById("carlenlist2").children;
				$api.removeCls(liList[0], 'on');
				var checklinum = 0;
				for (var i = 0; i < liList.length; i++) {
					if($api.hasCls(liList[i], 'on')) {
						checklinum++;
					}
				}
				for (var i = 0; i < liList2.length; i++) {
					if($api.hasCls(liList2[i], 'on')) {
						checklinum++;
					}
				}
				if(!$api.hasCls(obj, 'on') && checklinum>2) {
					toast('车长最多选择三项');
					return;
				}
			}
			$api.toggleCls(obj,'on');
		}
		function selGoodstype(obj) {
			document.activeElement.blur();
			goodstype = $api.attr(obj,'data-goodstype');
			var liList = document.getElementById("goodstypelist").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i], 'on')
			}
			$api.toggleCls(obj,'on');
		}
		function changeaddr(obj,id) {
			var len = $api.val(obj).length;
			if(len>=50)
			{
				$api.val(obj,$api.val(obj).substr(0,50));
				$api.text($api.byId("tishimsg"+id),'50/50');
			}
			else
			{
				$api.text($api.byId("tishimsg"+id),len+'/50');
			}
		}
		function setloadtime(times) {
			var jsontimes = $api.strToJson(times);
			$api.val($api.byId('loadtime'),jsontimes.content);
			entruckingtime = jsontimes.timestrap;
			entruckingtimetype = jsontimes.timetype;
		}
		function selLoadingTime() {
			document.activeElement.blur();
			setTimeout(function(){
				api.openFrame({
					name: 'settime_frm',
					url: 'settime_frm.html',
					bounces: false,
					rect: {
						x: 0,
						y: 0,
						w: 'auto',
						h: 'auto'
					},
					bgColor: 'rgba(0,0,0,0.6)',
					pageParam: {
						fromwin: 'addgoods'
					}
				});	
			}, 200);
			
		}
		function yichu(el) {
			api.confirm({
				msg: '移除该图片？',
				buttons: ['确定', '取消']
			}, function(ret, err) {
				var index = ret.buttonIndex;
				if(index == 1){
					$api.remove(el);
					var imgList = document.getElementsByClassName("addimg");
					if (imgList.length > 0) {
						$api.removeCls($api.byId('delbtn'),'display-none');
					}
					//$api.text($api.byId('tishimsg4'),imgList.length+'/3');
					
				}
			});
		}
		function upimg() {
			document.activeElement.blur();
			api.actionSheet({
				//title: '上传图片',
				cancelTitle: '取消',
				buttons: ['拍照', '从手机相册选择'],
				style: {
					layerColor:'rgba(0,0,0,0.3)',         //遮蔽层颜色，仅支持 rgba颜色，默认值：rgba（0, 0, 0, 0.4）
					itemNormalColor:'#fff',    //选项按钮正常状态背景颜色，支持#000、#000000、rgb、rgba，默认值：#F1F1F1
					itemPressColor:'#f5f5f5',     //选项按钮按下时背景颜色，支持#000、#000000、rgb、rgba，默认值：#E6E6E6
					fontNormalColor:'#333',    //选项按钮正常状态文字颜色，支持#000、#000000、rgb、rgba，默认值：#007AFF
					fontPressColor:'#000',     //选项按钮按下时文字颜色，支持#000、#000000、rgb、rgba，默认值：#0060F0
					titleFontColor:'#000'      //标题文字颜色，支持#000、#000000、rgb、rgba，默认值：#8F8F8F
				}
			}, function(ret, err) {
				if(ret.buttonIndex==1 || ret.buttonIndex==2)
				{
					getPictures(ret.buttonIndex);
				}
			});
		}
		function openAlbum() {
			getPictures(2);
		}
		function openCamera() {
			getPictures(1);
		}
		function getPictures(index){
			var perdesc = '相册/本地存储';
			var sourceType = 'library';
			var callbakstr = openAlbum;
            if(index==1){
				var pername = new Array('storage','camera');
				sourceType = 'camera';
				perdesc = '相册/拍照';
				callbakstr = openCamera;
				
				if (api.systemType == "android") {
					if(!confirmPerarr(pername,perdesc,callbakstr)){
						return;
					}
				}
			}
			else
			{
				var pername = 'photos';
				if (api.systemType == "android") {
					if(pername == 'photos')
					{
						pername = 'storage';
					}
					if(!confirmPer(pername,perdesc,callbakstr)){
						return;
					}
				}
			}			
			api.getPicture({
				sourceType: sourceType,
				encodingType: 'png',
				mediaValue: 'pic',
				targetWidth: 600,
			}, function(ret, err) {
			// 获取图片数据并处理
				if (ret) {
					var imgSrc = ret.data;
					if (imgSrc != "") {
					
						getPicture(imgSrc);
					}
				}
			});
		}
		function getPicture(imgurl) {
			console.log(imgurl+'getPicture');
			var imgs = $api.dom("#imgslist");
			//alert($api.html($api.dom(".clearfix")));
			var imgList = document.getElementsByClassName("addimg");
				if (imgList.length >= 3) {
					$api.addCls($api.byId('delbtn'),'display-none');
					api.toast({
						msg : '不能再添加啦',
						duration : 3000,
						location : 'bottom'
					});
				} else {
					var dcc = document.createElement("li");
					dcc.setAttribute("class", "addimg");
					dcc.setAttribute("tapmode", "imgpress");
					dcc.setAttribute("onclick", "yichu(this)");
					dcc.innerHTML = '<img src="' + imgurl + '" tapmode /><em></em>';
					prependChild(dcc, imgs);
					
					if (imgList.length > 2) {
						
						$api.addCls($api.byId('delbtn'),'display-none');
					}
				}

		}
		function prependChild(html, el) {
			if (el.hasChildNodes()) {
				el.insertBefore(html, el.firstChild);
			} else {
				el.appendChild(html);
			}
			var imgList = document.getElementsByClassName("addimg");
				if (imgList.length >= 3) {
					$api.addCls($api.byId('delbtn'),'display-none');
				}
				else
				{
					$api.removeCls($api.byId('delbtn'),'display-none');
				}
			//alert($api.html($api.dom(".clearfix")));
		}
		function setCityold(type) {
			//选择地区
			document.activeElement.blur();//收起键盘
			var UIActionSelector = api.require('UIActionSelector');
			UIActionSelector.open({
				datas: 'widget://res/city.json',
				iPhoneXBottomHeight: 0,
				layout: {
					row: 5,
					col: 3,
					height: 30,
					size: 12,
					sizeActive: 14,
					rowSpacing: 5,
					colSpacing: 10,
					maskBg: 'rgba(0,0,0,0.3)',
					bg: '#fff',
					color: '#464646',
					colorSelected: '#000'
				},
				animation: true,
				cancel: {
					text: '取消',
					size: 15,
					w: 70,
					h: 35,
					bg: '#fff',
					bgActive: '#fff',
					color: '#333',
					colorActive: '#3262F1'
				},
				ok: {
					text: '确定',
					size: 15,
					w: 70,
					h: 35,
					bg: '#fff',
					bgActive: '#fff',
					color: '#3262F1',
					colorActive: '#333'
				},
				title: {
					text: '',
					size: 12,
					h: 45,
					bg: '#fff',
					color: '#FDF8F4'
				},
				lineColor: '#DEDEDE',
				//actives: ['天津市',0,2]
			}, function(ret, err) {
				if (ret) {
					if(ret.eventType == 'ok')
					{
						area = ret.level1+'/'+ret.level2+'/'+ret.level3;
						$api.html($api.byId(type+'area'), '<p class="color-333">'+ret.level1+''+ret.level2+''+ret.level3+'</p>');
						//$api.text($api.byId('area'),ret.level1+'/'+ret.level2+'/'+ret.level3);
						//alert(JSON.stringify(ret.selectedInfo));
						if(type == 'send')
						{
							sendprovinceId = ret.selectedInfo[0].id;
							sendcityId = ret.selectedInfo[1].id;
							sendareaId = ret.selectedInfo[2].id;
						}
						else
						{
							destprovinceId = ret.selectedInfo[0].id;
							destcityId = ret.selectedInfo[1].id;
							destareaId = ret.selectedInfo[2].id;
						}
						
						
					}
					//alert(JSON.stringify(ret));
				} else {
					//alert(JSON.stringify(err));
				}
			});
		}
		function setLoadTime() {
			//选择地区
			var todaytime =	new Date(
				new Date(new Date().toLocaleDateString()).getTime()
			); 
			todaytime = Math.round(todaytime / 1000).toString();
			var todayshijianduanarr = [{name:'全天',id:0}];
			
			var todaycom = new Date();
			var curhour = todaycom.getHours();
			if(curhour > 0 && curhour < 5) {
				//当前时间凌晨0-5点显示凌晨
				todayshijianduanarr.push({name:'凌晨',id:1});
			}
			if(curhour > 0 && curhour < 11) {
				//当前时间凌晨0-5点显示凌晨
				todayshijianduanarr.push({name:'上午',id:2});
			}
			if(curhour > 0 && curhour < 17) {
				//当前时间凌晨0-5点显示凌晨
				todayshijianduanarr.push({name:'下午',id:3});
			}
			if(curhour > 0 && curhour < 22) {
				//当前时间凌晨0-5点显示凌晨
				todayshijianduanarr.push({name:'晚上',id:4});
			}
			
			var todaytimearr = [];
			todaytimearr[0] = [{name:'都可以',id:-1}];
			
			if(curhour > 0 && curhour < 5) {
				//当前时间凌晨0-5点显示凌晨
				todaytimearr[1] = [{name:'都可以',id:-1}];
				var curhh = parseInt(curhour) + 2;
				for(var i=curhh;i<7;i++)
				{
					todaytimearr[1].push({name:i+':00',id:i});
				}
			}
			else
			{
				todaytimearr[1] = [{name:'都可以',id:-1}];
				for(var i=0;i<7;i++)
				{
					todaytimearr[1].push({name:i+':00',id:i});
				}
			}
			if(curhour > 6 && curhour < 11) {
				//当前时间上午
				todaytimearr[2] = [{name:'都可以',id:-1}];
				var curhh = parseInt(curhour) + 2;
				for(var i=curhh;i<13;i++)
				{
					todaytimearr[2].push({name:i+':00',id:i});
				}
			}
			else
			{
				todaytimearr[2] = [{name:'都可以',id:-1}];
				for(var i=7;i<13;i++)
				{
					todaytimearr[2].push({name:i+':00',id:i});
				}
			}
			if(curhour > 12 && curhour < 17) {
				//当前时间下午
				todaytimearr[3] = [{name:'都可以',id:-1}];
				var curhh = parseInt(curhour) + 2;
				for(var i=curhh;i<19;i++)
				{
					todaytimearr[3].push({name:i+':00',id:i});
				}
			}
			else
			{
				todaytimearr[3] = [{name:'都可以',id:-1}];
				for(var i=13;i<19;i++)
				{
					todaytimearr[3].push({name:i+':00',id:i});
				}
			}
			if(curhour > 18 && curhour < 22) {
				//当前时间晚上
				todaytimearr[4] = [{name:'都可以',id:-1}];
				var curhh = parseInt(curhour) + 2;
				for(var i=curhh;i<24;i++)
				{
					todaytimearr[4].push({name:i+':00',id:i});
				}
			}
			else
			{
				todaytimearr[4] = [{name:'都可以',id:-1}];
				for(var i=19;i<24;i++)
				{
					todaytimearr[4].push({name:i+':00',id:i});
				}
			}
			var shijianduanarr = [{name:'全天',id:0},{name:'凌晨',id:1},{name:'上午',id:2},{name:'下午',id:3},{name:'晚上',id:4}];

			var timearr = [
				[{name:'都可以',id:-1}],
				[{name:'都可以',id:-1},{name:'00:00',id:0},{name:'1:00',id:1},{name:'2:00',id:2},{name:'3:00',id:3},{name:'4:00',id:4},{name:'5:00',id:5},{name:'6:00',id:6}],
				[{name:'都可以',id:-1},{name:'7:00',id:7},{name:'8:00',id:8},{name:'9:00',id:9},{name:'10:00',id:10},{name:'11:00',id:11},{name:'12:00',id:12}],
				[{name:'都可以',id:-1},{name:'13:00',id:13},{name:'14:00',id:14},{name:'15:00',id:15},{name:'16:00',id:16},{name:'17:00',id:17},{name:'18:00',id:18}],
				[{name:'都可以',id:-1},{name:'19:00',id:19},{name:'20:00',id:20},{name:'21:00',id:21},{name:'22:00',id:22},{name:'23:00',id:23}]
			];
			var datearr = [];
			for(var i=0;i<7;i++)
			{
				var curval = getDay(i);
				if(i==0)
				{
					curval.name = '今天';
				}
				else if(i==1)
				{
					curval.name = '明天';
				}
				var sublevel = [];
				if(i == 0) {
					for(var item in todayshijianduanarr)
					{
						var subinfo = {};
						subinfo.name = todayshijianduanarr[item].name;
						subinfo.id = todayshijianduanarr[item].id;
						subinfo.sub = todaytimearr[todayshijianduanarr[item].id];
						sublevel.push(subinfo);
					}
				}
				else
				{
					for(var item in shijianduanarr)
					{
						var subinfo = {};
						subinfo.name = shijianduanarr[item].name;
						subinfo.id = shijianduanarr[item].id;
						subinfo.sub = timearr[shijianduanarr[item].id];
						sublevel.push(subinfo);
					}
				}
				curval.sub = sublevel;
				//alert(JSON.stringify(sublevel));
				datearr.push(curval);
			}
			console.log(JSON.stringify(datearr));
			
			var level1index = 0,level2index = 0,level3index = 0;
			var levelarr1 = [];
			//for(var item in datearr) {
				
			//}
			
			
			document.activeElement.blur();//收起键盘
			var UIActionSelector = api.require('UIActionSelector');
			UIActionSelector.open({
				datas: datearr,
				iPhoneXBottomHeight: 0,
				layout: {
					row: 5,
					col: 3,
					height: 30,
					size: 12,
					sizeActive: 14,
					rowSpacing: 5,
					colSpacing: 10,
					maskBg: 'rgba(0,0,0,0.3)',
					bg: '#fff',
					color: '#999',
					colorSelected: '#000'
				},
				animation: true,
				cancel: {
					text: '取消',
					size: 15,
					w: 70,
					h: 35,
					bg: '#fff',
					bgActive: '#fff',
					color: '#333',
					colorActive: '#3262F1'
				},
				ok: {
					text: '确定',
					size: 15,
					w: 70,
					h: 35,
					bg: '#fff',
					bgActive: '#fff',
					color: '#3262F1',
					colorActive: '#333'
				},
				title: {
					text: '',
					size: 12,
					h: 45,
					bg: '#fff',
					color: '#FDF8F4'
				},
				lineColor: '#ddd',
				lineHeight: 1,
				actives: [0,0,0]
			}, function(ret, err) {
				if (ret) {
					if(ret.eventType == 'ok')
					{
						var seltime = ret.level1+' '+ret.level2+' '+ret.level3;
						$api.val($api.byId('loadtime'),seltime);
						entruckingtime = ret.selectedInfo[0].id;
						entruckingtimes = ret.selectedInfo[1].id;
						entruckingtimetype = ret.selectedInfo[2].id;
					}
					//alert(JSON.stringify(ret));
				} else {
					//alert(JSON.stringify(err));
				}
			});
		}
		function getDay(day){
			
			var today = new Date();
			var targetday_milliseconds=today.getTime() + 1000*60*60*24*day;
			today.setTime(targetday_milliseconds); //注意，这行是关键代码
			var tYear = today.getFullYear();
			var tMonth = today.getMonth();
			var tDate = today.getDate();
			tMonth = doHandleMonth(tMonth + 1);
			tDate = doHandleMonth(tDate);
			//return tMonth+"月"+tDate+"日";
			//return tYear+"-"+tMonth+"-"+tDate;
			var trandate = Date.parse(new Date(tYear+"-"+tMonth+"-"+tDate+" 00:00:00"))||Date.parse(new Date(tYear+"/"+tMonth+"/"+tDate+" 00:00:00"));
			var ret = {
				name: tMonth+"月"+tDate+"日",
				id: Math.round(trandate/1000).toString()
			};
			return ret;
		}
		function doHandleMonth(month){
			var m = month;
			if(month.toString().length == 1){
			 m = "0" + month;
			}
			return m;
		}
 
		//渲染数据
		function UpdateList(domId,templateId,jsondata,isAppend) {
			//console.log(JSON.stringify(jsondata));
			var act_content = $api.byId(domId);
			var tempFn = doT.template($api.byId(templateId).innerHTML);
			var resultText = tempFn(jsondata);
			//alert(isAppend);
			//console.log(resultText);
			if(isAppend)
			{
				$api.append(act_content, resultText);
			}
			else
			{
				$api.html(act_content, resultText);
			}
			api.parseTapmode();
		}
	</script>
</html>